package cn.omisheep.autt.util;

import cn.omisheep.autt.core.Cookies;
import cn.omisheep.commons.util.web.JSONUtils;
import com.fasterxml.jackson.core.type.TypeReference;

import java.util.Map;

public class SerializeUtil {

    private static final TypeReference<Map<String, Map<String, Cookies>>> tr = new TypeReference<Map<String, Map<String, Cookies>>>() {};

    private SerializeUtil() {
        throw new UnsupportedOperationException();
    }

    public static String serializationObjectByJson(Object obj) {
        return JSONUtils.toJSONString(obj);
    }

    public static Object deserializationObjectByJson(String str) { // 反序列化
        return JSONUtils.parseJSON(str, tr);
    }

}